package com.kingdee.eas.fdc.customerservice.client;

import com.kingdee.bos.ctrl.swing.event.SelectorEvent;
import com.kingdee.bos.dao.query.SQLExecutorFactory;
import com.kingdee.bos.metadata.data.SortType;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.entity.SorterItemCollection;
import com.kingdee.bos.metadata.entity.SorterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.jdbc.rowset.IRowSet;

public class CMSJoinCheckBillEditUICTEx extends CMSJoinCheckBillEditUI {

	public CMSJoinCheckBillEditUICTEx() throws Exception {
		super();
		// TODO Auto-generated constructor stub
	}
	
	
	protected void initRoom() throws Exception {
		// TODO Auto-generated method stub
		//super.initRoom();
		
		this.prmtRoom.getQueryAgent().resetRuntimeEntityView();

	   // this.prmtRoom.setQueryInfo("com.kingdee.eas.fdc.customerservice.app.RoomCMSQuery");

	    EntityViewInfo view = new EntityViewInfo();
	    FilterInfo filter = new FilterInfo();

	    String id = "";

	    if (null != getUIContext().get("sellprojectId"))
	      id = getUIContext().get("sellprojectId").toString();
	    else {
	      id = this.editData.getSellProject().getId().toString();
	    }
	    String sql="select fisforShe from T_SHE_SellProject where fid='"+id+"'";
	      IRowSet rs=SQLExecutorFactory.getRemoteInstance(sql).executeSQL();
	        if(rs.next()){
	        boolean num=rs.getBoolean("fisforShe");
	         if(num){
	        	 //com.kingdee.eas.fdc.customerservice.app.RoomCheckQuery
	        	 this.prmtRoom.setQueryInfo("com.kingdee.eas.fdc.customerservice.app.RoomCMSQuery");
	        	 
	        	filter.getFilterItems().add(new FilterItemInfo("sellproject.id", id));

	     	    filter.getFilterItems().add(new FilterItemInfo("room.sellState", "Sign"));

	     	   filter.getFilterItems().add(new FilterItemInfo("lastSignContract.state", "4AUDITTED")); 
	          }else{
	        	  this.prmtRoom.setQueryInfo("com.kingdee.eas.fdc.customerservice.app.RoomQuery");
	        	  filter.getFilterItems().add(new FilterItemInfo("sellProject.name", editData.getSellProject().getName(), CompareType.EQUALS));
	        	  filter.getFilterItems().add(new FilterItemInfo("roomCustomerSetting.isPayMan", true, CompareType.EQUALS));
	        	  //filter.getFilterItems().add(new FilterItemInfo("sellproject.id", id)); 
	        	  
	          }
	         
	        }

	    view.setFilter(filter);

	    SorterItemCollection collection = new SorterItemCollection();
	    SorterItemInfo sit = new SorterItemInfo("name");
	    sit.setSortType(SortType.DESCEND);
	    collection.add(sit);
	    view.setSorter(collection);
	    this.prmtRoom.setEntityViewInfo(view);
	}

}
